package org.zn.note.jdk.java8.Java8InAction.bean;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * @ClassName Apple
 * @Author zn
 * @Date 2020/1/3 9:56
 **/
public class Apple {
    private String color;
    private int weight;
    private static AtomicInteger count = new AtomicInteger(0);
    public int number = 0;

    public Apple() {
        number = count.incrementAndGet();
    }

    public Apple(String color, int weight) {
        number = count.incrementAndGet();
        this.color = color;
        this.weight = weight;
    }

    public static boolean isRedApple(Apple a) {
        return "red".equals(a.getColor());
    }

    public static List<Apple> getApples() {
        List<Apple> apples = new ArrayList<>();
        apples.add(new Apple("red", 100));
        apples.add(new Apple("red", 120));
        apples.add(new Apple("red", 150));
        apples.add(new Apple("red", 200));
        apples.add(new Apple("green", 100));
        apples.add(new Apple("green", 120));
        apples.add(new Apple("green", 150));
        apples.add(new Apple("green", 200));
        return apples;
    }

    public int getWeight() {
        return weight;
    }

    public void setWeight(int weight) {
        this.weight = weight;
    }

    public String getColor() {
        return color;
    }

    public void setColor(String color) {
        this.color = color;
    }

    public String toString() {
        return "number:" + number + ", color:" + color + ", weight:" + weight;
    }
}
